package services;

import java.io.*;
import java.net.Socket;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.*;

import model.Clientes;

public class ClientesServices extends Thread {

	protected Socket sk;
	protected DataOutputStream dos;
	protected DataInputStream dis;
	private int id;
	private List<Clientes> lista;
	
	public ClientesServices(){
		System.out.println("entro");
		try {       
            Socket socket = new Socket("127.0.0.1",9999);
            
            try {
                ObjectInputStream objectInput = new ObjectInputStream(socket.getInputStream()); //Error Line!
                try {
                    Object object = objectInput.readObject();
                    lista =  (List<Clientes>) object;
                    /*System.out.println(titleList.get(1));*/
                } catch (ClassNotFoundException e) {
                    System.out.println("The title list has not come from the server");
                    e.printStackTrace();
                }
            } catch (IOException e) {
                System.out.println("The socket for reading the object has problem");
                e.printStackTrace();
            }           
        } catch (UnknownHostException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } 
	}
	
	public List<Clientes> GetListaClientes(){
		return lista;
	}
}